import "@typespec/rest";
import "@typespec/http";
import "@azure-tools/typespec-azure-core";

using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.Core;

namespace Azure.Language.Authoring;

union ProjectKind {
  string,

  /**
   * For building a classification model to classify text using your own data. Each
   * file will have only one label. For example, file 1 is classified as A and file
   * 2 is classified as B.
   */
  CustomSingleLabelClassification: "CustomSingleLabelClassification",

  /**
   * For building a classification model to classify text using your own data. Each
   * file can have one or many labels. For example, file 1 is classified as A, B,
   * and C and file 2 is classified as B and C.
   */
  CustomMultiLabelClassification: "CustomMultiLabelClassification",

  /**
   * For building an extraction model to identify your domain categories using your
   * own data.
   */
  CustomEntityRecognition: "CustomEntityRecognition",
}

/**
 * Human-readable error code.
 */
union ErrorCode {
  string,

  /**
   * InvalidRequest
   */
  InvalidRequest: "InvalidRequest",

  /**
   * InvalidArgument
   */
  InvalidArgument: "InvalidArgument",

  /**
   * Unauthorized
   */
  Unauthorized: "Unauthorized",

  /**
   * Forbidden
   */
  Forbidden: "Forbidden",

  /**
   * NotFound
   */
  NotFound: "NotFound",

  /**
   * ProjectNotFound
   */
  ProjectNotFound: "ProjectNotFound",

  /**
   * OperationNotFound
   */
  OperationNotFound: "OperationNotFound",

  /**
   * AzureCognitiveSearchNotFound
   */
  AzureCognitiveSearchNotFound: "AzureCognitiveSearchNotFound",

  /**
   * AzureCognitiveSearchIndexNotFound
   */
  AzureCognitiveSearchIndexNotFound: "AzureCognitiveSearchIndexNotFound",

  /**
   * TooManyRequests
   */
  TooManyRequests: "TooManyRequests",

  /**
   * AzureCognitiveSearchThrottling
   */
  AzureCognitiveSearchThrottling: "AzureCognitiveSearchThrottling",

  /**
   * AzureCognitiveSearchIndexLimitReached
   */
  AzureCognitiveSearchIndexLimitReached: "AzureCognitiveSearchIndexLimitReached",

  /**
   * InternalServerError
   */
  InternalServerError: "InternalServerError",

  /**
   * ServiceUnavailable
   */
  ServiceUnavailable: "ServiceUnavailable",

  /**
   * Timeout
   */
  Timeout: "Timeout",

  /**
   * QuotaExceeded
   */
  QuotaExceeded: "QuotaExceeded",

  /**
   * Conflict
   */
  Conflict: "Conflict",

  /**
   * Warning
   */
  Warning: "Warning",
}

/**
 * Human-readable error code.
 */
union InnerErrorCode {
  string,

  /**
   * InvalidRequest
   */
  InvalidRequest: "InvalidRequest",

  /**
   * InvalidParameterValue
   */
  InvalidParameterValue: "InvalidParameterValue",

  /**
   * KnowledgeBaseNotFound
   */
  KnowledgeBaseNotFound: "KnowledgeBaseNotFound",

  /**
   * AzureCognitiveSearchNotFound
   */
  AzureCognitiveSearchNotFound: "AzureCognitiveSearchNotFound",

  /**
   * AzureCognitiveSearchThrottling
   */
  AzureCognitiveSearchThrottling: "AzureCognitiveSearchThrottling",

  /**
   * ExtractionFailure
   */
  ExtractionFailure: "ExtractionFailure",

  /**
   * InvalidRequestBodyFormat
   */
  InvalidRequestBodyFormat: "InvalidRequestBodyFormat",

  /**
   * EmptyRequest
   */
  EmptyRequest: "EmptyRequest",

  /**
   * MissingInputDocuments
   */
  MissingInputDocuments: "MissingInputDocuments",

  /**
   * InvalidDocument
   */
  InvalidDocument: "InvalidDocument",

  /**
   * ModelVersionIncorrect
   */
  ModelVersionIncorrect: "ModelVersionIncorrect",

  /**
   * InvalidDocumentBatch
   */
  InvalidDocumentBatch: "InvalidDocumentBatch",

  /**
   * UnsupportedLanguageCode
   */
  UnsupportedLanguageCode: "UnsupportedLanguageCode",

  /**
   * InvalidCountryHint
   */
  InvalidCountryHint: "InvalidCountryHint",
}

union StringIndexType {
  string,

  /**
   * The offset and length values will correspond to UTF-16 code units. Use this
   * option if your application is written in a language that support Unicode, for
   * example Java, JavaScript.
   */
  Utf16CodeUnit: "Utf16CodeUnit",
}

union StringIndexTypeAutoGenerated {
  string,

  /**
   * The offset and length values will correspond to UTF-16 code units. Use this
   * option if your application is written in a language that support Unicode, for
   * example Java, JavaScript.
   */
  Utf16CodeUnit: "Utf16CodeUnit",
}

union EvaluationKind {
  string,

  /**
   * Split the data into training and test sets according to user-defined
   * percentages.
   */
  Percentage: "percentage",

  /**
   * Split the data according to the chosen dataset for every example in the data.
   */
  Manual: "manual",
}

union JobStatus {
  string,

  /**
   * notStarted
   */
  NotStarted: "notStarted",

  /**
   * running
   */
  Running: "running",

  /**
   * succeeded
   */
  Succeeded: "succeeded",

  /**
   * failed
   */
  Failed: "failed",

  /**
   * cancelled
   */
  Cancelled: "cancelled",

  /**
   * cancelling
   */
  Cancelling: "cancelling",

  /**
   * partiallyCompleted
   */
  PartiallyCompleted: "partiallyCompleted",
}

/**
 * Represents a list of retrieved projects' metadata.
 */
model ProjectsMetadata is Azure.Core.Page<ProjectMetadata>;

/**
 * Represents the metadata of a project.
 */
@resource("authoring/analyze-text/projects")
model ProjectMetadata {
  /**
   * Represents the project creation datetime.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  createdDateTime: utcDateTime;

  /**
   * Represents the project last modification datetime.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastModifiedDateTime: utcDateTime;

  /**
   * Represents the project last training datetime.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastTrainedDateTime?: utcDateTime;

  /**
   * Represents the project last deployment datetime.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastDeployedDateTime?: utcDateTime;

  /**
   * The project kind.
   */
  projectKind: ProjectKind;

  /**
   * The storage container name.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  storageInputContainerName: string;

  /**
   * The project settings.
   */
  settings?: unknown;

  /**
   * The new project name.
   */
  projectName: string;

  /**
   * Whether the project would be used for multiple languages or not.
   */
  multilingual?: boolean;

  /**
   * The project description.
   */
  description?: string;

  /**
   * The project language. This is BCP-47 representation of a language. For example,
   * use "en" for English, "en-gb" for English (UK), "es" for Spanish etc.
   */
  language: string;
}

/**
 * Error response.
 */
@error
model ErrorResponse {
  /**
   * The error object.
   */
  error: Error;
}

/**
 * The error object.
 */
model Error {
  ...Record<unknown>;

  /**
   * One of a server-defined set of error codes.
   */
  code: ErrorCode;

  /**
   * A human-readable representation of the error.
   */
  message: string;

  /**
   * The target of the error.
   */
  target?: string;

  /**
   * An array of details about specific errors that led to this reported error.
   */
  details?: Error[];

  /**
   * An object containing more specific information than the current object about
   * the error.
   */
  innererror?: InnerErrorModel;
}

/**
 * An object containing more specific information about the error. As per
 * Microsoft One API guidelines -
 * https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses.
 */
model InnerErrorModel {
  /**
   * One of a server-defined set of error codes.
   */
  code: InnerErrorCode;

  /**
   * Error message.
   */
  message: string;

  /**
   * Error details.
   */
  details?: Record<string>;

  /**
   * Error target.
   */
  target?: string;

  /**
   * An object containing more specific information than the current object about
   * the error.
   */
  innererror?: InnerErrorModel;
}

/**
 * Represents the options used to create or update a project.
 */
model CreateProjectOptions {
  /**
   * The project kind.
   */
  projectKind: ProjectKind;

  /**
   * The storage container name.
   */
  storageInputContainerName: string;

  /**
   * The project settings.
   */
  settings?: unknown;

  /**
   * The new project name.
   */
  projectName: string;

  /**
   * Whether the project would be used for multiple languages or not.
   */
  multilingual?: boolean;

  /**
   * The project description.
   */
  description?: string;

  /**
   * The project language. This is BCP-47 representation of a language. For example,
   * use "en" for English, "en-gb" for English (UK), "es" for Spanish etc.
   */
  language: string;
}

/**
 * Represents an exported project.
 */
model ExportedProject {
  /**
   * The version of the exported file.
   */
  projectFileVersion: string;

  /**
   * Specifies the method used to interpret string offsets. For additional
   * information see https://aka.ms/text-analytics-offsets.
   */
  stringIndexType: StringIndexTypeAutoGenerated;

  /**
   * Represents the project metadata.
   */
  metadata: CreateProjectOptions;

  /**
   * Represents the project assets.
   */
  assets?: ExportedProjectAssets;
}

/**
 * Represents the assets of an exported project.
 */
@discriminator("projectKind")
model ExportedProjectAssets {
  /**
   * The type of the project the assets belong to.
   */
  projectKind: ProjectKind;
}

/**
 * Represents the options for starting a new training job.
 */
model TrainingJobOptions {
  /**
   * Represents the output model label.
   */
  modelLabel: string;

  /**
   * Represents training config version.
   */
  trainingConfigVersion: string;

  /**
   * Represents the evaluation options. By default, the evaluation kind is
   * percentage, with training split percentage as 80, and testing split percentage
   * as 20.
   */
  evaluationOptions?: EvaluationOptions;
}

/**
 * Represents the options used running the evaluation.
 */
model EvaluationOptions {
  /**
   * Represents the evaluation kind. By default, the evaluation kind is set to
   * percentage.
   */
  kind?: EvaluationKind;

  /**
   * Represents the training dataset split percentage. Only needed in case the
   * evaluation kind is percentage.
   */
  trainingSplitPercentage?: int32;

  /**
   * Represents the testing dataset split percentage. Only needed in case the
   * evaluation kind is percentage.
   */
  testingSplitPercentage?: int32;
}

/**
 * Represents a list of retrieved deployments.
 */
model ProjectDeployments is Azure.Core.Page<ProjectDeployment>;

/**
 * Represents a project deployment.
 */
@resource("authoring/analyze-text/projects/{projectName}/deployments")
model ProjectDeployment {
  /**
   * Represents deployment name.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  deploymentName: string;

  /**
   * Represents deployment modelId.
   */
  modelId: string;

  /**
   * Represents deployment last trained time.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastTrainedDateTime: utcDateTime;

  /**
   * Represents deployment last deployed time.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastDeployedDateTime: utcDateTime;

  /**
   * Represents deployment expiration date in the runtime.
   */
  deploymentExpirationDate: plainDate;

  /**
   * Represents model training config version.
   */
  modelTrainingConfigVersion: string;
}

/**
 * Represents the options for swapping two deployments together.
 */
model SwapDeploymentsOptions {
  /**
   * Represents the first deployment name.
   */
  firstDeploymentName: string;

  /**
   * Represents the second deployment name.
   */
  secondDeploymentName: string;
}

/**
 * Represents the options for creating or updating a project deployment.
 */
model CreateDeploymentOptions {
  /**
   * Represents the trained model label.
   */
  trainedModelLabel: string;
}

/**
 * Represents the state of a deployment job.
 */
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"
model DeploymentJobState extends JobState {}

/**
 * Represents a job's state.
 */
model JobState {
  /**
   * The job ID.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  jobId: string;

  /**
   * The creation date time of the job.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  createdDateTime: utcDateTime;

  /**
   * The last date time the job was updated.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastUpdatedDateTime: utcDateTime;

  /**
   * The expiration date time of the job.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  expirationDateTime?: utcDateTime;

  /**
   * The job status.
   */
  status: JobStatus;

  /**
   * The warnings that were encountered while executing the job.
   */
  warnings?: Warning[];

  /**
   * The errors encountered while executing the job.
   */
  errors?: Error[];
}

/**
 * Represents a warning that was encountered while executing the request.
 */
model Warning {
  /**
   * The warning code.
   */
  code: string;

  /**
   * The warning message.
   */
  message: string;
}

/**
 * Represents the state of an export job.
 */
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"
model ExportProjectJobState extends JobState {
  /**
   * The URL to use in order to download the exported project.
   */
  resultUrl?: string;
}

/**
 * Represents the state of an import job.
 */
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"
model ImportProjectJobState extends JobState {}

/**
 * Represents a list of retrieved trained models.
 */
model ProjectTrainedModels is Azure.Core.Page<ProjectTrainedModel>;

/**
 * Represents a trained model.
 */
@resource("authoring/analyze-text/projects/{projectName}/models")
model ProjectTrainedModel {
  /**
   * The trained model label.
   */
  label: string;

  /**
   * The model ID.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  modelId: string;

  /**
   * The last trained date time of the model.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  lastTrainedDateTime: utcDateTime;

  /**
   * The duration of the model's last training request in seconds.
   */
  lastTrainingDurationInSeconds: int32;

  /**
   * The model expiration date.
   */
  modelExpirationDate: plainDate;

  /**
   * The model training config version.
   */
  modelTrainingConfigVersion: string;
}

/**
 * Represents a list of results for an evaluation operation.
 */
model EvaluationResults is Azure.Core.Page<DocumentEvaluationResult>;

/**
 * Represents the evaluation result of a document.
 */
@discriminator("projectKind")
model DocumentEvaluationResult {
  /**
   * Represents the document path.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  location: string;

  /**
   * Represents the document language. This is BCP-47 representation of a language.
   * For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish
   * etc.
   */
  language: string;

  /**
   * Represents the project kind.
   */
  projectKind: ProjectKind;
}

/**
 * Represents the summary for an evaluation operation.
 */
@discriminator("projectKind")
model EvaluationSummary {
  /**
   * Represents the project type that the evaluation ran on.
   */
  projectKind: ProjectKind;

  /**
   * Represents the options used running the evaluation.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  evaluationOptions: EvaluationOptions;
}

/**
 * Represents a list of retrieved training jobs.
 */
model TrainingJobs is Azure.Core.Page<TrainingJobState>;

/**
 * Represents the state of a training job.
 */
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"
model TrainingJobState extends JobState {
  /**
   * Represents training tasks detailed result.
   */
  result: TrainingJobResult;
}

/**
 * Represents the output of a training job.
 */
model TrainingJobResult {
  /**
   * Represents trained model label.
   */
  modelLabel: string;

  /**
   * Represents training config version.
   */
  trainingConfigVersion: string;

  /**
   * Represents model train status.
   */
  trainingStatus: SubTrainingJobState;

  /**
   * Represents model evaluation status.
   */
  evaluationStatus?: SubTrainingJobState;

  /**
   * Represents the estimate end date time for training and evaluation.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  estimatedEndDateTime?: utcDateTime;
}

/**
 * Represents the detailed state of a training sub-operation.
 */
model SubTrainingJobState {
  /**
   * Represents progress percentage.
   */
  percentComplete: int32;

  /**
   * Represents the start date time.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  startDateTime?: utcDateTime;

  /**
   * Represents the end date time.
   */
  // FIXME: (utcDateTime) Please double check that this is the correct type for your scenario.
  endDateTime?: utcDateTime;

  /**
   * Represents the status of the sub-operation.
   */
  status: JobStatus;
}

/**
 * Represents the state of a project deletion job.
 */
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "For backward compatibility"
model ProjectDeletionJobState extends JobState {}

/**
 * Represents a list of retrieved languages.
 */
model SupportedLanguages is Azure.Core.Page<SupportedLanguage>;

/**
 * Represents a supported language.
 */
@resource("authoring/analyze-text/projects/global/languages")
model SupportedLanguage {
  /**
   * The language name.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  languageName: string;

  /**
   * The language code. This is BCP-47 representation of a language. For example,
   * "en" for English, "en-gb" for English (UK), "es" for Spanish etc.
   */
  languageCode: string;
}

/**
 * Represents a list of training config versions.
 */
model TrainingConfigVersions is Azure.Core.Page<TrainingConfigVersion>;

/**
 * Represents a training config version.
 */
model TrainingConfigVersion {
  /**
   * Represents the version of the config.
   */
  // FIXME: (resource-key-guessing) - Verify that this property is the resource key, if not please update the model with the right one
  @key
  trainingConfigVersion: string;

  /**
   * Represents the training config version expiration date.
   */
  modelExpirationDate: plainDate;
}

/**
 * Represents a cell in a confusion matrix.
 */
model ConfusionMatrixCell {
  /**
   * Represents normalized value in percentages.
   */
  normalizedValue: float32;

  /**
   * Represents raw value.
   */
  rawValue: float32;
}

/**
 * Represents the document evaluation result for a custom entity recognition
 * project.
 */
model CustomEntityRecognitionDocumentEvaluationResult
  extends DocumentEvaluationResult {
  /**
   * Represents the evaluation prediction for entity recognition.
   */
  customEntityRecognitionResult: DocumentEntityRecognitionEvaluationResult;

  /**
   * Represents the project kind.
   */
  projectKind: "CustomEntityRecognition";
}

/**
 * Represents the entity recognition evaluation result for a document.
 */
model DocumentEntityRecognitionEvaluationResult {
  /**
   * Represents the document labelled entities.
   */
  entities: DocumentEntityRegionEvaluationResult[];
}

/**
 * Represents the evaluation comparison between the expected and predicted
 * entities of a document region.
 */
model DocumentEntityRegionEvaluationResult {
  /**
   * Represents the region's expected entity labels.
   */
  expectedEntities: DocumentEntityLabelEvaluationResult[];

  /**
   * Represents the region's predicted entity labels.
   */
  predictedEntities: DocumentEntityLabelEvaluationResult[];

  /**
   * Represents the region offset.
   */
  regionOffset: int32;

  /**
   * Represents the region length.
   */
  regionLength: int32;
}

/**
 * Represents an evaluation result entity label.
 */
model DocumentEntityLabelEvaluationResult {
  /**
   * Represents the entity category.
   */
  category: string;

  /**
   * Represents the entity offset index relative to the original text.
   */
  offset: int32;

  /**
   * Represents the entity length.
   */
  length: int32;
}

/**
 * Represents the evaluation summary for a custom entity recognition project.
 */
model CustomEntityRecognitionEvaluationSummary extends EvaluationSummary {
  /**
   * Contains the data related to extraction evaluation.
   */
  customEntityRecognitionEvaluation: EntityRecognitionEvaluationSummary;

  /**
   * Represents the project type that the evaluation ran on.
   */
  projectKind: "CustomEntityRecognition";
}

/**
 * Represents the evaluation summary for a custom entity recognition project.
 */
model EntityRecognitionEvaluationSummary {
  /**
   * Represents the confusion matrix between two entities (the two entities can be
   * the same). The matrix is between the entity that was labelled and the entity
   * that was predicted.
   */
  confusionMatrix: Record<Record<ConfusionMatrixCell>>;

  /**
   * Represents the entities evaluation
   */
  entities: Record<EntityEvaluationSummary>;

  /**
   * Represents the micro F1
   */
  microF1: float32;

  /**
   * Represents the micro precision
   */
  microPrecision: float32;

  /**
   * Represents the micro recall
   */
  microRecall: float32;

  /**
   * Represents the macro F1
   */
  macroF1: float32;

  /**
   * Represents the macro precision
   */
  macroPrecision: float32;

  /**
   * Represents the macro recall
   */
  macroRecall: float32;
}

/**
 * Represents the evaluation summary for an entity.
 */
model EntityEvaluationSummary {
  /**
   * Represents the model precision
   */
  f1: float64;

  /**
   * Represents the model recall
   */
  precision: float64;

  /**
   * Represents the model F1 score
   */
  recall: float64;

  /**
   * Represents the count of true positive
   */
  truePositiveCount: int32;

  /**
   * Represents the count of true negative
   */
  trueNegativeCount: int32;

  /**
   * Represents the count of false positive
   */
  falsePositiveCount: int32;

  /**
   * Represents the count of false negative
   */
  falseNegativeCount: int32;
}

/**
 * Represents the document evaluation result for a custom multi-label
 * classification project.
 */
model CustomMultiLabelClassificationDocumentEvaluationResult
  extends DocumentEvaluationResult {
  /**
   * Represents the evaluation prediction for multi label classification.
   */
  customMultiLabelClassificationResult: DocumentMultiLabelClassificationEvaluationResult;

  /**
   * Represents the project kind.
   */
  projectKind: "CustomMultiLabelClassification";
}

/**
 * Represents the comparison between the expected and predicted classes that are
 * result from the evaluation operation.
 */
model DocumentMultiLabelClassificationEvaluationResult {
  /**
   * Represents the document's expected classes.
   */
  expectedClasses: string[];

  /**
   * Represents the document's predicted classes.
   */
  predictedClasses: string[];
}

/**
 * Represents the evaluation summary for a custom multi-label classification
 * project.
 */
model CustomMultiLabelClassificationEvaluationSummary
  extends EvaluationSummary {
  /**
   * Contains the data related to multi label classification evaluation.
   */
  customMultiLabelClassificationEvaluation: MultiLabelClassificationEvaluationSummary;

  /**
   * Represents the project type that the evaluation ran on.
   */
  projectKind: "CustomMultiLabelClassification";
}

/**
 * Represents the evaluation summary for a multi-label classification project.
 */
model MultiLabelClassificationEvaluationSummary {
  /**
   * Represents the classes evaluation
   */
  classes: Record<MultiLabelClassEvaluationSummary>;

  /**
   * Represents the micro F1
   */
  microF1: float32;

  /**
   * Represents the micro precision
   */
  microPrecision: float32;

  /**
   * Represents the micro recall
   */
  microRecall: float32;

  /**
   * Represents the macro F1
   */
  macroF1: float32;

  /**
   * Represents the macro precision
   */
  macroPrecision: float32;

  /**
   * Represents the macro recall
   */
  macroRecall: float32;
}

/**
 * Represents the evaluation summary of a class in a multi-label classification
 * project.
 */
model MultiLabelClassEvaluationSummary {
  /**
   * Represents the model precision
   */
  f1: float64;

  /**
   * Represents the model recall
   */
  precision: float64;

  /**
   * Represents the model F1 score
   */
  recall: float64;

  /**
   * Represents the count of true positive
   */
  truePositiveCount: int32;

  /**
   * Represents the count of true negative
   */
  trueNegativeCount: int32;

  /**
   * Represents the count of false positive
   */
  falsePositiveCount: int32;

  /**
   * Represents the count of false negative
   */
  falseNegativeCount: int32;
}

/**
 * Represents the document evaluation result for a custom single-label
 * classification project.
 */
model CustomSingleLabelClassificationDocumentEvaluationResult
  extends DocumentEvaluationResult {
  /**
   * Represents the evaluation prediction for single label classification.
   */
  customSingleLabelClassificationResult: DocumentSingleLabelClassificationEvaluationResult;

  /**
   * Represents the project kind.
   */
  projectKind: "CustomSingleLabelClassification";
}

/**
 * Represents the comparison between the expected and predicted class that result
 * from an evaluation operation.
 */
model DocumentSingleLabelClassificationEvaluationResult {
  /**
   * Represents the document's expected class.
   */
  expectedClass: string;

  /**
   * Represents the document's predicted class.
   */
  predictedClass: string;
}

/**
 * Represents the evaluation summary for a custom single-label classification
 * project.
 */
model CustomSingleLabelClassificationEvaluationSummary
  extends EvaluationSummary {
  /**
   * Contains the data related to single label classification evaluation.
   */
  customSingleLabelClassificationEvaluation: SingleLabelClassificationEvaluationSummary;

  /**
   * Represents the project type that the evaluation ran on.
   */
  projectKind: "CustomSingleLabelClassification";
}

/**
 * Represents the evaluation summary for a custom single-label classification
 * project.
 */
model SingleLabelClassificationEvaluationSummary {
  /**
   * Represents the confusion matrix between two classes (the two classes can be the
   * same). The matrix is between the class that was labelled and the class that was
   * predicted.
   */
  confusionMatrix: Record<Record<ConfusionMatrixCell>>;

  /**
   * Represents the classes evaluation
   */
  classes: Record<SingleLabelClassEvaluationSummary>;

  /**
   * Represents the micro F1
   */
  microF1: float32;

  /**
   * Represents the micro precision
   */
  microPrecision: float32;

  /**
   * Represents the micro recall
   */
  microRecall: float32;

  /**
   * Represents the macro F1
   */
  macroF1: float32;

  /**
   * Represents the macro precision
   */
  macroPrecision: float32;

  /**
   * Represents the macro recall
   */
  macroRecall: float32;
}

/**
 * Represents the evaluation summary for a class in a single-label classification
 * project.
 */
model SingleLabelClassEvaluationSummary {
  /**
   * Represents the model precision
   */
  f1: float64;

  /**
   * Represents the model recall
   */
  precision: float64;

  /**
   * Represents the model F1 score
   */
  recall: float64;

  /**
   * Represents the count of true positive
   */
  truePositiveCount: int32;

  /**
   * Represents the count of true negative
   */
  trueNegativeCount: int32;

  /**
   * Represents the count of false positive
   */
  falsePositiveCount: int32;

  /**
   * Represents the count of false negative
   */
  falseNegativeCount: int32;
}

/**
 * Represents a class of an exported project.
 */
model ExportedClass {
  /**
   * The class category.
   */
  category?: string;
}

/**
 * Represents an exported document for a custom entity recognition project.
 */
model ExportedCustomEntityRecognitionDocument {
  /**
   * The list of entity labels belonging to the document.
   */
  entities?: ExportedDocumentRegion[];

  /**
   * The location of the document in the storage.
   */
  location?: string;

  /**
   * Represents the document language. This is BCP-47 representation of a language.
   * For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish
   * etc.
   */
  language?: string;

  /**
   * The dataset for this document. Allowed values are 'Train' and 'Test'.
   */
  dataset?: string;
}

/**
 * Represents a region in a document for entity labeling.
 */
model ExportedDocumentRegion {
  /**
   * Start position for the region.
   */
  regionOffset?: int32;

  /**
   * Length for the region text.
   */
  regionLength?: int32;

  /**
   * The list of entity labels belonging to this region.
   */
  labels?: ExportedDocumentEntityLabel[];
}

/**
 * Represents an entity label for a document.
 */
model ExportedDocumentEntityLabel {
  /**
   * The entity category.
   */
  category?: string;

  /**
   * Start position for the entity text.
   */
  offset?: int32;

  /**
   * Length for the entity text.
   */
  length?: int32;
}

/**
 * Represents the exported assets for a entity recognition project.
 */
model ExportedCustomEntityRecognitionProjectAssets
  extends ExportedProjectAssets {
  /**
   * The list of entities belonging to the project.
   */
  entities?: ExportedEntity[];

  /**
   * The list of documents belonging to the project.
   */
  documents?: ExportedCustomEntityRecognitionDocument[];

  /**
   * The type of the project the assets belong to.
   */
  projectKind: "CustomEntityRecognition";
}

/**
 * Represents an entity in an exported project.
 */
model ExportedEntity {
  /**
   * The entity category.
   */
  category?: string;
}

/**
 * Represents an exported document of a custom multi-label classification project.
 */
model ExportedCustomMultiLabelClassificationDocument {
  /**
   * The document classes.
   */
  classes?: ExportedDocumentClass[];

  /**
   * The location of the document in the storage.
   */
  location?: string;

  /**
   * Represents the document language. This is BCP-47 representation of a language.
   * For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish
   * etc.
   */
  language?: string;

  /**
   * The dataset for this document. Allowed values are 'Train' and 'Test'.
   */
  dataset?: string;
}

/**
 * Represents a classification label for a document.
 */
model ExportedDocumentClass {
  category?: string;
}

/**
 * Represents the exported assets for a custom multi-label classification project.
 */
model ExportedCustomMultiLabelClassificationProjectAssets
  extends ExportedProjectAssets {
  /**
   * The list of classes in the project.
   */
  classes?: ExportedClass[];

  /**
   * The list of documents in the project.
   */
  documents?: ExportedCustomMultiLabelClassificationDocument[];

  /**
   * The type of the project the assets belong to.
   */
  projectKind: "CustomMultiLabelClassification";
}

/**
 * Represents an exported document for a custom single-label classification
 * project.
 */
model ExportedCustomSingleLabelClassificationDocument {
  /**
   * The class of the documents.
   */
  class?: ExportedDocumentClass;

  /**
   * The location of the document in the storage.
   */
  location?: string;

  /**
   * Represents the document language. This is BCP-47 representation of a language.
   * For example, use "en" for English, "en-gb" for English (UK), "es" for Spanish
   * etc.
   */
  language?: string;

  /**
   * The dataset for this document. Allowed values are 'Train' and 'Test'.
   */
  dataset?: string;
}

/**
 * Represents the exported assets for a single-label classification project.
 */
model ExportedCustomSingleLabelClassificationProjectAssets
  extends ExportedProjectAssets {
  /**
   * The list of classes belonging to this project.
   */
  classes?: ExportedClass[];

  /**
   * The list of documents belonging to this project.
   */
  documents?: ExportedCustomSingleLabelClassificationDocument[];

  /**
   * The type of the project the assets belong to.
   */
  projectKind: "CustomSingleLabelClassification";
}
